package mirrormonkey.core.tools.entities;

import mirrormonkey.core.annotations.ClientSideConstructor;
import mirrormonkey.core.annotations.EntityHierarchy;
import mirrormonkey.framework.annotations.IdentityAware;
import mirrormonkey.framework.entity.EntityData;
import mirrormonkey.framework.entity.SyncEntity;

import com.jme3.math.Vector3f;
import com.jme3.scene.Geometry;
import com.jme3.scene.shape.Box;

@EntityHierarchy
public class CreatableBox extends Geometry implements SyncEntity {

	public static final String NAMED_CONSTR = "named";

	private EntityData data;

	@ClientSideConstructor
	public CreatableBox() {
		super("Box", new Box(Vector3f.ZERO, 0.5f, 0.5f, 0.5f));
	}

	@ClientSideConstructor
	public CreatableBox(String name, Vector3f pos) {
		super(name, new Box(Vector3f.ZERO, 0.5f, 0.5f, 0.5f));
		setLocalTranslation(pos);
	}

	@ClientSideConstructor
	public CreatableBox(@IdentityAware CreatableBox previous) {
		super("" + (Integer.parseInt(previous.getName()) + 1), new Box(
				Vector3f.ZERO, 0.5f, 0.5f, 0.5f));
		Vector3f pos = previous.getLocalTranslation().clone();
		pos.x += 1.5f;
		setName(name);
		setLocalTranslation(pos);
	}

	@ClientSideConstructor(NAMED_CONSTR)
	public CreatableBox(Object name) {
		super((String) name, new Box(Vector3f.ZERO, 1, 1, 1));
	}

	@ClientSideConstructor
	public CreatableBox(@IdentityAware CreatableSphere sphere) {
		super(sphere.getName(), new Box(Vector3f.ZERO, 0.5f, 0.5f, 0.5f));
		setLocalTranslation(sphere.getLocalTranslation());
	}

	@Override
	public void setData(EntityData data) {
		this.data = data;
	}

	@Override
	public EntityData getData() {
		return data;
	}

}
